package faw.car.ccentersdk.prop;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.Objects;

/**
 * @Author zhuima
 * 注册，解注册回调的参数
 */
public class HQRegisterParameter implements Parcelable {

    private static final String TAG = "HQRegisterParameter";

    private int mPropertyId;
    private int mIdentify;
    private String mProcessName;

    private long mTimeStamp;

    // support key
    private String mPropertyKey;

    public HQRegisterParameter(int mPropertyId, int mIdentify, String mProcessName) {
        this.mPropertyId = mPropertyId;
        this.mIdentify = mIdentify;
        this.mProcessName = mProcessName;
        mTimeStamp = System.currentTimeMillis();
    }

    public HQRegisterParameter(String mPropertyKey, int mIdentify, String mProcessName) {
        this.mPropertyKey = mPropertyKey;
        this.mIdentify = mIdentify;
        this.mProcessName = mProcessName;
        mTimeStamp = System.currentTimeMillis();
    }

    public void setTimeStamp(long mTimeStamp) {
        this.mTimeStamp = mTimeStamp;
    }

    public long getTimeStamp() {
        return mTimeStamp;
    }

    public int getPropertyId() {
        return mPropertyId;
    }

    public void setPropertyId(int mPropertyId) {
        this.mPropertyId = mPropertyId;
    }

    public int getIdentify() {
        return mIdentify;
    }

    public void setIdentify(int mIdentify) {
        this.mIdentify = mIdentify;
    }

    public String getProcessName() {
        return mProcessName;
    }

    public void setProcessName(String mProcessName) {
        this.mProcessName = mProcessName;
    }

    public void setPropertyKey(String propertyKey) {
        this.mPropertyKey = propertyKey;
    }

    public String getPropertyKey() {
        return mPropertyKey;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.mPropertyId);
        dest.writeInt(this.mIdentify);
        dest.writeString(this.mProcessName);
        dest.writeLong(this.mTimeStamp);
//        dest.writeString(this.mPropertyKey);
    }

    public void readFromParcel(Parcel source) {
        this.mPropertyId = source.readInt();
        this.mIdentify = source.readInt();
        this.mProcessName = source.readString();
        this.mTimeStamp = source.readLong();
//        this.mPropertyKey = source.readString();
    }

    public HQRegisterParameter() {
    }

    protected HQRegisterParameter(Parcel in) {
        readFromParcel(in);
    }

    public static final Creator<HQRegisterParameter> CREATOR = new Creator<HQRegisterParameter>() {
        @Override
        public HQRegisterParameter createFromParcel(Parcel source) {
            return new HQRegisterParameter(source);
        }

        @Override
        public HQRegisterParameter[] newArray(int size) {
            return new HQRegisterParameter[size];
        }
    };

    @Override
    public String toString() {
        return "HQRegisterParameter{" +
                "mPropertyId=" + mPropertyId +
                ", mIdentify=" + mIdentify +
                ", mProcessName='" + mProcessName + '\'' +
                ", mTimeStamp=" + mTimeStamp +
                ", mPropertyKey='" + mPropertyKey + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof HQRegisterParameter)) return false;
        HQRegisterParameter that = (HQRegisterParameter) o;
        return mPropertyId == that.mPropertyId
                && mIdentify == that.mIdentify
                && mTimeStamp == that.mTimeStamp
                && Objects.equals(mProcessName, that.mProcessName)
                && Objects.equals(mPropertyKey, that.mPropertyKey);
    }

    @Override
    public int hashCode() {
        return Objects.hash(mPropertyId, mIdentify, mProcessName, mTimeStamp, mPropertyKey);
    }
}
